# define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
	int x, y;
	scanf("%d %d", &x, &y);
	if (x < 0)
		x = -x;
	if (y < 0)
		y = -y;
	while (y != 0)
	{
		int t = y;
		y = x % y;
		x = t;
	}
	printf("%d\n", x);
	return 0;
}